const request = require("../../../api/index")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    autoplay: true,
    interval: 5000,
    imageUrl: [{
      url: 'http://allhope.work/img/ca1.jpg',
    },
    {
      url: 'http://allhope.work/img/ca2.jpg',
    },
    {
      url: 'http://allhope.work/img/ca3.jpg',
    },
    {
      url: 'http://allhope.work/img/ca4.jpg',
    }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad(options) {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },


  /**
   * 跳转维修
   */
  ToRepair() {
    let user = wx.getStorageSync('user')
    // 判断是否登录
    if (user != '') {
      // 判断是否为维修者
      if (user.repair == 1) {
        wx.navigateTo({
          url: '../Repair/Repair',
        })
      } else {
        // 判断是否填写完整信息
        if (user.repair != 0) {
          wx.navigateTo({
            url: '../useRepair/userRepair',
          })
        } else {
          wx.navigateTo({
            url: '../../mine/Info/Info?to=/miniprogram/pages/CA/useRepair/userRepair',
          })
        }
      }
    } else {
      console.log('Not login, Please login')
      wx.navigateTo({
        url: '../../mine/login/login?to=/miniprogram/pages/CA/useRepair/userRepair',
      })
    }
  },

  /**
   * 跳转历史
   */
  ToHistory() {
    let user = wx.getStorageSync('user')
    // 判断是否登录
    if (user != '') {
      // 判断是否为维修者
      if (user.is_repair == 1) {
        wx.navigateTo({
          url: '../Repair/Repair?to=history',
        })
      } else {
        // 判断是否填写完整信息
        if (user.is_repair != undefined) {
          wx.navigateTo({
            url: '../History/History',
          })
        } else {
          wx.navigateTo({
            url: '../../mine/Info/Info?to=/miniprogram/pages/CA/History/History',
          })
        }
      }
    } else {
      console.log('Not login, Please login')
      wx.navigateTo({
        url: '../../mine/login/login?to=/miniprogram/pages/CA/History/History',
      })
    }
  },

  /**
   * 跳转新闻
   */
  ToNews() {
    wx.navigateTo({
      url: '../News/News',
    })
  },

  /**
   * 跳转到活动主页
   */
  ToActivity() {
    wx.navigateTo({
      url: '../ActivityMain/ActivityMain',
    })
  },

  /**
     * 右上角分享
     */
  onShareAppMessage: function () {
    return {
      title: '首页',
      path: '/pages/CA/home/home',
      imageUrl: '../../../images/share.png'
    }
  },



})